package zgc.demo.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import zgc.demo.consumer.entity.Goods;
import zgc.demo.consumer.feignApi.GoodsFeignClient;

import java.util.Map;

@RestController
@RequestMapping("/order4")
public class OrderController04 {

    /**
     * 注入feign提供远程调用，简化rest+ribbon
     */
    @Autowired
    private GoodsFeignClient goodsFeignClient;


    /**
     * 使用负载均衡器监护rest实现远程接口调用
     *
     * @param goodsId
     * @return
     */
    @GetMapping("/getGoodsById/{goodsId}")
    public Map<String, Goods> getGoodsById(@PathVariable("goodsId") String goodsId) {
        //5.feign远程调用,简化rest+ribbon远程调用
        return goodsFeignClient.getGoodsById(goodsId);

    }

}
